start_hour = int(input())
start_minite = int(input())
duration = int(input())

end_time = start_hour * 60 + start_minite + duration
end_hour = end_time // 60
end_minite = end_time % 60

print(end_hour)
print(end_minite)
